package com.yin.myproject.distributedlock;

import java.util.concurrent.TimeUnit;

/**
 * 分布式锁接口定义
 *
 * @author Eason
 * @create 2018-03-06 10:39
 **/
public interface DistributedLock {

    /**
     * 获取锁,如果没有得到就等待
     *
     * @throws Exception
     */
    public void acquire() throws Exception;

    /**
     * 获取锁直到超时
     *
     * @param time
     * @param timeUnit
     * @return
     * @throws Exception
     */
    public boolean acquire(long time, TimeUnit timeUnit) throws Exception;

    /**
     * 释放锁
     *
     * @throws Exception
     */
    public void release() throws Exception;
}
